# tested against MSVC 2017 which included 3.11.* 2018/07/05
cmake_minimum_required(VERSION 3.5.1)
-project(gpsbabel)
+project(gpsbabel LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Find the Qt5Core library
find_package(Qt5 COMPONENTS Core REQUIRED)
-message("Qt5Core_VERSION String describing the version of the module: \"${Qt5Core_VERSION}\"")
-message("Qt5Core_LIBRARIES List of libraries for use with the target_link_libraries command: \"${Qt5Core_LIBRARIES}\"")
-message("Qt5Core_INCLUDE_DIRS List of directories for use with the include_directories command: \"${Qt5Core_INCLUDE_DIRS}\"")
-message("Qt5Core_DEFINITIONS List of definitions for use with add_definitions: \"${Qt5Core_DEFINITIONS}\"")
-message("Qt5Core_COMPILE_DEFINITIONS List of definitions for use with the COMPILE_DEFINITIONS target property: \"${Qt5Core_COMPILE_DEFINITIONS}\"")
-message("Qt5Core_FOUND Boolean describing whether the module was found successfully: \"${Qt5Core_FOUND}\"")
-message("Qt5Core_EXECUTABLE_COMPILE_FLAGS String of flags to be used when building executables: \"${Qt5Core_EXECUTABLE_COMPILE_FLAGS}\"")
-if (${Qt5Core_VERSION} VERSION_LESS 5.9)
+if(${Qt5Core_VERSION} VERSION_LESS 5.9)
message(FATAL_ERROR "Qt version ${Qt5Core_VERSION} found, but version 5.9 or newer is required.")
+else()
+ message(STATUS "Using Qt5 version ${Qt5Core_VERSION}")
endif()
-include_directories(AFTER SYSTEM ${Qt5Core_INCLUDE_DIRS})
-add_definitions(${Qt5Core_DEFINITIONS})
set(MINIMAL_FMTS
magproto.cc explorist_ini.cc gpx.cc geo.cc mapsend.cc garmin.cc
set(JEEPS
jeeps/gpsapp.cc jeeps/gpscom.cc
- jeeps/gpsmath.cc jeeps/gpsmem.cc
+ jeeps/gpsmath.cc jeeps/gpsmem.cc
jeeps/gpsprot.cc jeeps/gpsread.cc
jeeps/gpsdevice.cc jeeps/gpsdevice_ser.cc jeeps/gpsdevice_usb.cc
jeeps/gpsrqst.cc jeeps/gpssend.cc jeeps/gpsserial.cc jeeps/jgpsutil.cc
gbfile.cc parse.cc session.cc main.cc globals.cc
src/core/textstream.cc
src/core/usasciicodec.cc
- src/core/xmlstreamwriter.cc
+ src/core/xmlstreamwriter.cc
)
set(HEADERS
include_directories(AFTER zlib)
-INCLUDE (CheckIncludeFile)
+include(CheckIncludeFile)
if(UNIX)
# this is used by zlib
- CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H)
+ check_include_file("unistd.h" HAVE_UNISTD_H)
if(${HAVE_UNISTD_H})
add_definitions(-DHAVE_UNISTD_H)
endif()
# this is used by zlib
- CHECK_INCLUDE_FILE("stdarg.h" HAVE_STDARG_H)
+ check_include_file("stdarg.h" HAVE_STDARG_H)
if(${HAVE_STDARG_H})
add_definitions(-DHAVE_STDARG_H)
endif()
add_compile_options(/MP -wd4100 -wd4267)
endif()
-if (UNIX AND NOT APPLE)
+if(UNIX AND NOT APPLE)
set(LIBS ${LIBS} usb-1.0)
endif()
-if (APPLE)
+if(APPLE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lobjc -framework IOKit -framework CoreFoundation")
include_directories(AFTER mac/libusb mac/libusb/Xcode)
set(SOURCES ${SOURCES}
add_definitions(-DCSVFMTS_ENABLED)
add_executable(gpsbabel ${SOURCES} ${HEADERS})
-target_link_libraries(gpsbabel ${Qt5Core_LIBRARIES} ${LIBS})
+target_link_libraries(gpsbabel Qt5::Core ${LIBS})
-message("Sources are:")
-message("${SOURCES}")
-message("Headers are:")
-message("${HEADERS}")
-message("Defines are:")
-get_directory_property( DirDefs COMPILE_DEFINITIONS)
-message("${DirDefs}")
-message("Libs are:")
-message("${LIBS}")
+message(STATUS "Sources are: \"${SOURCES}\"")
+message(STATUS "Headers are: \"${HEADERS}\"")
+get_directory_property(DirDefs COMPILE_DEFINITIONS)
+message(STATUS "Defines are: \"${DirDefs}\"")
+get_target_property(LnkLibs gpsbabel LINK_LIBRARIES)
+message(STATUS "Libs are: \"${LnkLibs}\"")
+get_directory_property(IncDirs INCLUDE_DIRECTORIES)
+message(STATUS "Include Directores are: \"${IncDirs}\"")
if(UNIX)
# the tests only work if the pwd is top level source dir due to the file name getting embedded in the file nonexistent.err.
# tested against MSVC 2017 which included 3.11.* 2018/07/05
cmake_minimum_required(VERSION 3.5.1)
-project(gpsbabelfe)
+project(gpsbabelfe LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD_REQUIRED True)
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTORCC ON)
# Find the Qt5Core library
-find_package(Qt5 COMPONENTS Core Gui Network Xml REQUIRED)
-#message("Qt5Core_VERSION String describing the version of the module: \"${Qt5Core_VERSION}\"")
-#message("Qt5Core_LIBRARIES List of libraries for use with the target_link_libraries command: \"${Qt5Core_LIBRARIES}\"")
-#message("Qt5Core_INCLUDE_DIRS List of directories for use with the include_directories command: \"${Qt5Core_INCLUDE_DIRS}\"")
-#message("Qt5Core_DEFINITIONS List of definitions for use with add_definitions: \"${Qt5Core_DEFINITIONS}\"")
-#message("Qt5Core_COMPILE_DEFINITIONS List of definitions for use with the COMPILE_DEFINITIONS target property: \"${Qt5Core_COMPILE_DEFINITIONS}\"")
-#message("Qt5Core_FOUND Boolean describing whether the module was found successfully: \"${Qt5Core_FOUND}\"")
-#message("Qt5Core_EXECUTABLE_COMPILE_FLAGS String of flags to be used when building executables: \"${Qt5Core_EXECUTABLE_COMPILE_FLAGS}\"")
-if (${Qt5Core_VERSION} VERSION_LESS 5.9)
+find_package(Qt5 COMPONENTS Core Gui Network Widgets Xml REQUIRED)
+list(APPEND QT_LIBRARIES Qt5::Core Qt5::Gui Qt5::Network Qt5::Widgets Qt5::Xml)
+if(${Qt5Core_VERSION} VERSION_LESS 5.9)
message(FATAL_ERROR "Qt version ${Qt5Core_VERSION} found, but version 5.9 or newer is required.")
+else()
+ message(STATUS "Using Qt5 version ${Qt5Core_VERSION}")
endif()
# hard code webengine instead of webkit for now
find_package(Qt5 COMPONENTS WebEngineWidgets WebChannel REQUIRED)
+list(APPEND QT_LIBRARIES Qt5::WebEngineWidgets Qt5::WebChannel)
+add_definitions(-DHAVE_WEBENGINE)
-set(QT_INCLUDE_DIRS ${Qt5Core_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5WebEngineWidgets_INCLUDE_DIRS} ${Qt5WebChannel_INCLUDE_DIRS})
-list(REMOVE_DUPLICATES QT_INCLUDE_DIRS)
-message("QT INCLUDE DIRS: \"${QT_INCLUDE_DIRS}\"\n")
-
-set(QT_DEFINITIONS ${Qt5Core_DEFINITIONS} ${QT5Gui_DEFINITIONS} ${Qt5Network_DEFINITIONS} ${Qt5Xml_DEFINITIONS} ${Qt5WebEngineWidgets_DEFINITIONS} ${Qt5WwebChannel_DEFINITIONS})
-list(REMOVE_DUPLICATES QT_DEFINITIONS)
-message("QT DEFS: \"${QT_DEFINITIONS}\"\n")
-
-set(QT_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5WebEngineWidgets_LIBRARIES} ${Qt5WebChannel_LIBRARIES})
-#list(REMOVE_DUPLICATES QT_LIBRARIES)
-message("QT LIBS: \"${QT_LIBRARIES}\"\n")
-
-include_directories(AFTER SYSTEM ${QT_INCLUDE_DIRS})
-add_definitions(${QT_DEFINITIONS} -DHAVE_WEBENGINE)
-
-if (APPLE)
+if(APPLE)
find_library(IOKIT_LIBRARIES IOKit)
find_library(COREFOUNDATION_LIBRARIES CoreFoundation)
endif()
-if (UNIX AND NOT APPLE)
+if(UNIX AND NOT APPLE)
find_package(PkgConfig REQUIRED)
pkg_check_modules(LIBUDEV libudev)
- if (${LIBUDEV_FOUND})
+ if(${LIBUDEV_FOUND})
add_definitions(-DHAVE_UDEV)
endif()
endif()
set(RESOURCES app.qrc)
-if (WIN32)
+if(WIN32)
set(RESOURCES ${RESOURCES} app.rc)
endif()
-if (UNIX AND NOT APPLE)
+if(UNIX AND NOT APPLE)
set(TARGET gpsbabelfe)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY GPSBabelFE)
else()
version_mismatch.cc
)
-if (UNIX AND NOT APPLE)
+if(UNIX AND NOT APPLE)
set(SOURCES ${SOURCES} serial_unix.cc)
-elseif (APPLE)
+elseif(APPLE)
set(SOURCES ${SOURCES} serial_mac.cc)
-elseif (WIN32)
+elseif(WIN32)
set(SOURCES ${SOURCES} serial_win.cc)
endif()
version_mismatch.h
)
-if (APPLE)
+if(APPLE)
set(MACOSX_BUNDLE_ICON_FILE appicon.icns)
set(ICON_FILE images/${MACOSX_BUNDLE_ICON_FILE})
set_source_files_properties(${ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
list(REMOVE_DUPLICATES LIBS)
target_link_libraries(${TARGET} ${LIBS})
-message("Sources are: \"${SOURCES}\"\n")
-message("Headers are: \"${HEADERS}\"\n")
+message(STATUS "Sources are: \"${SOURCES}\"")
+message(STATUS "Headers are: \"${HEADERS}\"")
get_directory_property(DirDefs COMPILE_DEFINITIONS)
-message("Defines are: \"${DirDefs}\"\n")
+message(STATUS "Defines are: \"${DirDefs}\"")
get_target_property(LnkLibs ${TARGET} LINK_LIBRARIES)
-message("Libs are: \"${LnkLibs}\"\n")
+message(STATUS "Libs are: \"${LnkLibs}\"")
get_directory_property(IncDirs INCLUDE_DIRECTORIES)
-message("Include Directores are: \"${IncDirs}\"\n")
+message(STATUS "Include Directores are: \"${IncDirs}\"")
-add_custom_target(package COMMAND ./package_app DEPENDS ${TARGET})
+add_custom_target(package_app COMMAND ./package_app DEPENDS ${TARGET})